﻿<shared:UserControlBase x:Class="HP.Cachalote.WPF.UserControls.UnfinishedTodoItemTreeViewItemUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:shared="clr-namespace:HP.Cachalote.WPF.Shared"
             xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:galaSoft="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             xmlns:validationRules="clr-namespace:HP.Cachalote.WPF.ValidationRules"
             xmlns:extendedAttachedProperties="clr-namespace:HP.Cachalote.WPF.ExtendedAttachedProperties"   
             xmlns:userControls="clr-namespace:HP.Cachalote.WPF.UserControls"
             mc:Ignorable="d" 
             d:DesignHeight="30" d:DesignWidth="500">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/StoryBoards/UnfinishedTodoItemTreeViewUserControlStoryBoard.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <UserControl.Triggers>
        <EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="GridMainContent">
            <BeginStoryboard Storyboard="{StaticResource StoryboardShowOptions}"/>
        </EventTrigger>
        <EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="GridMainContent">
            <BeginStoryboard Storyboard="{StaticResource StoryboardHideOptions}"/>
        </EventTrigger>
    </UserControl.Triggers>
    <Grid x:Name="GridMainContent" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type TreeView}, AncestorLevel=1}, 
						Path=ActualWidth, Converter={StaticResource NumberSubtractionConverter}, ConverterParameter=30}">
        <Grid.RenderTransform>
            <TransformGroup>
                <ScaleTransform/>
                <SkewTransform/>
                <RotateTransform/>
                <TranslateTransform/>
            </TransformGroup>
        </Grid.RenderTransform>
        <Grid.Style>
            <Style TargetType="{x:Type Grid}">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="AliceBlue" />
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Grid.Style>
        <Grid.ColumnDefinitions>
            <!-- CheckBox for set TodoItem as Done -->
            <ColumnDefinition Width="Auto" />
            <!-- TextBox for TodoItem display & edit -->
            <ColumnDefinition />
            <!-- Due Time Display -->
            <ColumnDefinition Width="Auto" />
            <!-- Note Icon -->
            <ColumnDefinition Width="Auto" />
            <!-- Menu -->
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <CheckBox x:Name="ChkDone" IsChecked="{Binding IsDone}" Style="{StaticResource BigCheckBoxStyle}" Margin="2,2,0,0" Opacity="0" Click="ChkDone_Clicked" />
        <TextBox Grid.Column="1" Padding="3" 
									extendedAttachedProperties:TextBoxExtendedAttachedProperties.TextBoxController="{Binding}" 
									Style="{StaticResource TodoItemTreeViewItemTextBox}">
            <TextBox.Text>
                <Binding Path="Title" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
                    <Binding.ValidationRules>
                        <validationRules:TodoItemTitleValidationRule />
                    </Binding.ValidationRules>
                </Binding>
            </TextBox.Text>
            <interactivity:Interaction.Triggers>
                <interactivity:EventTrigger EventName="KeyDown">
                    <galaSoft:EventToCommand Command="{Binding TextBoxTitleOnKeyDownCommand}" PassEventArgsToCommand="True" />
                </interactivity:EventTrigger>
                <interactivity:EventTrigger EventName="LostFocus">
                    <interactivity:InvokeCommandAction Command="{Binding TextBoxTitleLostFocusCommand}" />
                </interactivity:EventTrigger>
                <interactivity:EventTrigger EventName="GotFocus">
                    <interactivity:InvokeCommandAction Command="{Binding TextBoxTitleGotFocusCommand}" />
                </interactivity:EventTrigger>
            </interactivity:Interaction.Triggers>
        </TextBox>
        <userControls:DueTimeDisplayUserControl Grid.Column="2" DataContext="{Binding DueTimeDisplayViewModel}" Width="180" />
        <Button Grid.Column="3" Margin="4,0,4,0"  Style="{StaticResource NoteImageButton}" Tag="{Binding ShowEditNoteControlCommand}" />
        <!-- TodoItem Setup Menu -->
        <Menu x:Name="Menu"  Height="22" Grid.Column="4" Margin="0,0,10,0" Opacity="0">
            <MenuItem Padding="4">
                <MenuItem.Header>
                    <Image Stretch="Fill" Source="/Resources/Images/Menu.png" Height="14" Width="13" />
                </MenuItem.Header>
                <MenuItem>
                    <MenuItem.Header>
                        <Grid Height="45" Width="100">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="22" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <TextBlock Grid.ColumnSpan="4" Margin="0,0,0,0" FontSize="12" Text="Priority"/>
                            <Button Margin="2" Grid.Row="1" Content="1" Background="#ff3300" Style="{StaticResource SetPriorityButton}" Command="{Binding SetToVeryHighPriorityCommand}" />
                            <Button Margin="2" Grid.Column="1" Grid.Row="1" Content="2" Background="#168bb8" Style="{StaticResource SetPriorityButton}" Command="{Binding SetToHighPriorityCommand}" />
                            <Button Margin="2" Grid.Column="2" Grid.Row="1" Content="3" Background="#6d9b17" Style="{StaticResource SetPriorityButton}" Command="{Binding SetToMediumPriorityCommand}" />
                            <Button Margin="2" Grid.Column="3" Grid.Row="1" Content="4" Background="#000000" Style="{StaticResource SetPriorityButton}" Command="{Binding SetToLowPriorityCommand}" />
                        </Grid>
                    </MenuItem.Header>
                </MenuItem>
                <Separator />
                <MenuItem Header="Delete" Command="{Binding DeleteCommand}" />
            </MenuItem>
        </Menu>
    </Grid>
</shared:UserControlBase>
